export default {

	namespaced: true,

	state: {
		formData: {
			enterpriseId: '',
			departmentId: '',
			departmentName: '',
			departments: [],
			departmentIds: [],
			name: '',
			email: '',
			mobile: '',
			position: '',
			contactSort: '999',
			contactLevel: '100',
			euserType:1,
			alias: '',
			gender: '1',
			birthday: '',
			address: '',
			politics: '114'
		}
	},

	mutations: {

		init (state, obj) {
			state.formData.enterpriseId = obj.enterpriseId;
			state.formData.departmentId = obj.departmentId;
			state.formData.departmentName = obj.departmentName;
			state.formData.name = obj.name;
			state.formData.email = obj.email||[];
			state.formData.mobile = obj.mobile;
			state.formData.position = obj.position||[];
			state.formData.contactSort = obj.contactSort;
			state.formData.contactLevel = obj.contactLevel;
		},

		getDepartments (state, departments) {
			if (departments.length == 0) {
				state.formData.departmentId = '';
				state.formData.departmentName = '';
				return ;
			}
			state.formData.departmentId = departments[0].departmentId;
			state.formData.departmentName = departments[0].departmentName;
		},

		setContactLevel (state, level) {
			state.formData.contactLevel = level;
		}
	}
}